from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtWebEngineWidgets import *
from PyQt5.QtPrintSupport import *

import abc
from abc import *

class Features:
    FEATURE_TAB_DISCARD = 0
    FEATURE_TAB_FREEZE = 1

    FEATURE_NATIVE_PLUGIN_JAVASCRIPT_INVOKE = 5

class Engine(QWidget):
    __metaclass__ = abc.ABCMeta
    parent = None
    index = -1

    TAB_STATUS_ACTIVE = 10
    TAB_STATUS_HIDDEN = 11
    TAB_STATUS_HIDDEN_LONG = 12

    def __init__(self, parent):
        super(QWidget, self).__init__(parent)
        self.parent = parent
        try:
            self.index = parent.getIndex()
        except Exception as e:
            print(e)
        self.layout = QVBoxLayout(self)
        self.layout.setContentsMargins(0, 0, 0, 0)

        self.toolbar = QToolBar()
        self.toolbar.layout = QHBoxLayout(self)
        self.toolbar.layout.setContentsMargins(0, 0, 0, 0)
        self.toolbar.setStyleSheet("QToolBar {height: 26px; max-height: 26px; padding: 0px; margin: 0px;}")

        self.layout.addWidget(self.toolbar)

    @abstractmethod
    def closeEngine(self):
        pass

    """
        TOOD: Move to supports(Feature.TAB_DISCARD)
    """
    @abstractmethod
    def supportsTabDiscard(self):
        return False

    @abstractmethod
    def tabState(self, state):
        pass

    @abstractmethod
    def supports(self, feature):
        return False

    @abstractmethod
    def forward(self):
        pass

    @abstractmethod
    def back(self):
        pass

    def __getIndex(self):
        return self.index